<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    /*
    * 正则表达式中点.匹配除回车外的任何单字符，标记『s』改变这种行为，允许行终止符出现
    * */
    let str = `
            <ul>
             <li>
             <a>肖生克的救赎</a>
             <p>上映日期: 1994-09-10</p>
             </li>
             <li>
             <a>阿甘正传</a>
             <p>上映日期: 1994-07-06</p>
             </li>
            </ul>`;
    //声明正则
    const reg = /<li>.*?<a>(.*?)<\/a>.*?<p>(.*?)<\/p>/gs; // g：全局匹配。 s：无视回车
    //执行匹配
    // let result = reg.exec(str);
    // console.log(result)

    let result;
    let data = [];
    while (result = reg.exec(str)) {
        console.log(result);
        data.push({title: result[1], time: result[2]});
    }
    //输出结果
    console.log(data);
</script>
</html>